/// https://leetcode.cn/problems/minimum-size-subarray-sum/submissions/558785812/

class Solution {
public:
    int minSubArrayLen(int target, vector<int>& nums) {
        using namespace std;
        int ans = 0x3f3f3f3f;
        int l =0, r = 0;

        int sum = 0;
        int d = nums.size();
        for (; r < d; r++) {
            sum += nums[r];
            while (sum >= target) {
                ans = min(ans, r-l+1);
                sum -= nums[l];
                l++;
            }
        }
        return ans == 0x3f3f3f3f ? 0 : ans;
    }
};